package com.beaven.imclient.data;

import com.beaven.imclient.adapter.UserAdapter;
import com.beaven.model.model.db.User;
import com.chad.library.adapter.base.entity.MultiItemEntity;

/**
 * author: Beaven
 * time: 2017/5/26 18:24
 */

public class ItemUser implements MultiItemEntity {

  private String id;
  private String name;
  private String status;
  private String categoryId;
  private String account;

  public ItemUser() {
  }

  public void setName(String name) {
    this.name = name;
  }

  public void setStatus(String status) {
    this.status = status;
  }

  public String getCategoryId() {
    return categoryId;
  }

  public void setCategoryId(String categoryId) {
    this.categoryId = categoryId;
  }

  public String getId() {
    return id;
  }

  public void setId(String id) {
    this.id = id;
  }

  public String getAccount() {
    return account;
  }

  public void setAccount(String account) {
    this.account = account;
  }

  public String getName() {
    return name;
  }

  public String getStatus() {
    return status;
  }

  @Override public int getItemType() {
    return UserAdapter.TYPE_USER;
  }

  @Override public String toString() {
    return "ItemUser{"
        + "name='"
        + name
        + '\''
        + ", status='"
        + status
        + '\''
        + ", categoryId='"
        + categoryId
        + '\''
        + '}';
  }

  public static ItemUser build(User user) {
    ItemUser itemUser = new ItemUser();
    itemUser.setName(user.getName());
    itemUser.setStatus(user.isOnline() ? "在线" : "离线");
    itemUser.setCategoryId(user.getCategoryId());
    itemUser.setId(user.getId());
    itemUser.setAccount(user.getAccount());
    return itemUser;
  }
}
